//
//  RHNetworkOptionVC.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/3/25.
//

#import "RHNetworkOptionVC.h"
#import "RHNetworkConfigVC.h"
#import "BLEScanViewController.h"

@interface RHNetworkOptionVC ()

@end

@implementation RHNetworkOptionVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"配网".rh_localized;
    self.view.backgroundColor = CFTabViewBgColor;
    [self setupUI];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

-(void)setupUI

{
    QMUIButton *bleBtn = [[QMUIButton alloc]init];
    [bleBtn setTitle:@"蓝牙配网".rh_localized forState:UIControlStateNormal];
    [bleBtn setTitleColor:kColorRGB(63, 38, 67) forState:UIControlStateNormal];
    bleBtn.titleLabel.font = kSYSTEMFONT(14);
    [bleBtn setImage:[UIImage imageNamed:@"network_ble"] forState:UIControlStateNormal];
    bleBtn.imagePosition = QMUIButtonImagePositionTop;
    bleBtn.spacingBetweenImageAndTitle = 10;
    bleBtn.backgroundColor = UIColor.whiteColor;
    bleBtn.titleLabel.numberOfLines = 0;
    [bleBtn setCornerRadius:8];
    [bleBtn rounded:8 width:1 color:kBorderColor];
    [self.view addSubview:bleBtn];
    [bleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_offset(20);
        make.width.offset((kUI_WINDOW_W-60)/2);
        make.height.equalTo(bleBtn.mas_width);
    }];
    
    QMUIButton *apBtn = [[QMUIButton alloc]init];
    [apBtn setTitle:@"WiFi配网".rh_localized forState:UIControlStateNormal];
    [apBtn setTitleColor:kColorRGB(63, 38, 67) forState:UIControlStateNormal];
    apBtn.titleLabel.font = kSYSTEMFONT(14);
    [apBtn setImage:[UIImage imageNamed:@"network_ap"] forState:UIControlStateNormal];
    apBtn.imagePosition = QMUIButtonImagePositionTop;
    apBtn.spacingBetweenImageAndTitle = 10;
    apBtn.backgroundColor = UIColor.whiteColor;
    apBtn.titleLabel.numberOfLines = 0;
    [apBtn setCornerRadius:8];
    [self.view addSubview:apBtn];
    [apBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(20);
        make.left.equalTo(bleBtn.mas_right).offset(20);
        make.width.height.equalTo(bleBtn);
    }];
    apBtn.hidden = YES;
    kWeakSelf;
    [[bleBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        BLEScanViewController *vc = [[BLEScanViewController alloc] init];
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    
    [[apBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        [weakSelf.navigationController pushViewController:[RHNetworkConfigVC new] animated:YES];
    }];
    
}

@end
